package com.xinchuang.controller.targetSystem.damage;

import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.dto.DeleteDto;
import com.xinchuang.entity.targetSystem.damage.TWarhead;
import com.xinchuang.service.targetSystem.damage.TWarheadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenyanming
 * @program systems-analysis
 * @description 战斗部管理
 * @date 2024/05/15
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/warhead")
@Api(value = "战斗部管理", tags = "战斗部管理")
public class TWarheadController {
    @Autowired
    private TWarheadService tWarheadService;

    @ApiOperation(value = "添加或修改导弹数据")
    @PostMapping("/insertOrUpdate")
    public Result insertOrUpdate(@RequestBody TWarhead tWarhead) {
        return tWarheadService.insertOrUpdate(tWarhead);
    }
    /**
     *
     * @param pageNum 页码
     * @param pageSize 页数
     * @param warheadName 战斗部名称
     * @param warheadType 战斗部类型
     * @param missileId 导弹id
     * @return
     */
    @ApiOperation(value = "分页查询列表数据")
    @GetMapping("/queryList")
    public R queryList(@RequestParam(value = "pageNum") Integer pageNum,
                                    @RequestParam(value = "pageSize") Integer pageSize,
                                    @RequestParam(value = "warheadName", required = false) String warheadName,
                                    @RequestParam(value = "warheadType", required = false) String warheadType,
                                    @RequestParam(value = "missileId", required = false) String missileId) {
        return R.data(tWarheadService.queryList(pageNum,pageSize,warheadName,warheadType,missileId));
    }


    /**
     * 根据ids批量删除
     * @param deleteDto
     * @return
     */
    @ApiOperation(value = "根据ids删除/批量删除数据")
    @DeleteMapping("/deleteByIds")
    public R deleteByIds(@RequestBody DeleteDto deleteDto) {
        return tWarheadService.deleteByIds(deleteDto.getIds(),deleteDto.getDeleteStatus());
    }

}
